import { NslUtil4Vue } from "@/utils/NslUtil4Vue";

/**
 * 根据关键字，导入指定目录下的component,生成 router可以用的 routes数组
 */
const componentNameArray=[
    'horizontal_layout_index_test',
    'vertical_layout_index_test',
    'logo_test',
    'logo2_test',
    'link_index_test',
    'svg_icon_index_test',
    'icon_text_item_index_test',
    'menu_index_test',
    'menu_item_test',
    'menu_item2_test',
    'demo1_test'
];
const modules = import.meta.glob('@/components/*/*_test.vue');
const componentTestRoutes=await NslUtil4Vue.createRoutesArray(modules,componentNameArray);

export {componentTestRoutes}

// console.log('in components test routes before promise');


// const modules = import.meta.glob('@/components/*/*_test.vue');
// const pathComponentMap=await NslUtil4Vue.getPathComponentMap(modules);

// console.log('in components test routes after promise');


// let componentTestRoutes:RouteRecordRaw[]=componentNameArray.map(componentName=>{
//     const keys=pathComponentMap.keys();
//     // console.log('keys',keys);
//     // console.log('componentName=',componentName);
//     for(let key of keys){
//         // console.log('componentName=',componentName);
//         // console.log('key=',key)
//         if(key.includes(componentName)){
//             return{
//                 name:componentName,
//                 path:componentName,
//                 component:pathComponentMap.get(key) as MyTypeComponentClass,
//                 meta:{
//                     title:componentName
//                 }
//             }
//         }
//     }
// }).filter(e=>e);//去掉undefined



// componentTestRoutes= componentTestRoutes.filter(e=>e);//过滤掉undefined，不过应该没有undefined

// console.log('componentTestRoutes',componentTestRoutes);

// const componentTestRoutes:RouteRecordRaw[]=[
//         {
//             name:'horizontal_layout_index_test',
//             path:'horizontal_layout_index_test',
//             component:horizontal_layout_index_test,
//             meta:{
//                 title:'horizontal_layout_index_test'
//             },
//         },
//         {
//             name:'vertical_layout_index_test',
//             path:'vertical_layout_index_test',
//             component:vertical_layout_index_test,
//             meta:{
//                 title:'vertical_layout_index_test'
//             },
//         },
//     ]

